<!DOCTYPE html>
<html lang="en">
<head>
    
    <meta charset="utf-8">
    <title>layer/layerManage.js - sss</title>
    
    <meta name="description" content="aaaa" />
    
        <meta name="keywords" content="cccc" />
        <meta name="keyword" content="cccc" />
    
    
    
    <meta property="og:title" content="arcgis4.x 简单的操作工具"/>
    <meta property="og:type" content="website"/>
    <meta property="og:image" content=""/>
    <meta property="og:site_name" content="CPC"/>
    <meta property="og:url" content="https://gitee.com/CPC1994/arcgis4.X"/>
    
    <script src="scripts/prettify/prettify.js"></script>
    <script src="scripts/prettify/lang-css.js"></script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
  <div class="navicon"></div>
</label>

<label for="nav-trigger" class="overlay"></label>

<nav class="wrap">
    
    <input type="text" id="nav-search" placeholder="Search" />
    
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="EchartLayer.html">EchartLayer</a><ul class='methods'><li data-type='method' style='display: none;'><a href="EchartLayer.html#init">init</a></li><li data-type='method' style='display: none;'><a href="EchartLayer.html#setBaseMap">setBaseMap</a></li><li data-type='method' style='display: none;'><a href="EchartLayer.html#setChartOption">setChartOption</a></li><li data-type='method' style='display: none;'><a href="EchartLayer.html#setVisible">setVisible</a></li><li data-type='method' style='display: none;'><a href="EchartLayer.html#refreshBegin">refreshBegin</a></li><li data-type='method' style='display: none;'><a href="EchartLayer.html#refreshing">refreshing</a></li><li data-type='method' style='display: none;'><a href="EchartLayer.html#refreshEnd">refreshEnd</a></li><li data-type='method' style='display: none;'><a href="EchartLayer.html#on">on</a></li><li data-type='method' style='display: none;'><a href="EchartLayer.html#off">off</a></li><li data-type='method' style='display: none;'><a href="EchartLayer.html#setCharts">setCharts</a></li><li data-type='method' style='display: none;'><a href="EchartLayer.html#createLayer">createLayer</a></li><li data-type='method' style='display: none;'><a href="EchartLayer.html#removeLayer">removeLayer</a></li><li data-type='method' style='display: none;'><a href="EchartLayer.html#startMapEventListeners">startMapEventListeners</a></li><li data-type='method' style='display: none;'><a href="EchartLayer.html#getE3CoordinateSystem">getE3CoordinateSystem</a></li></ul></li><li></li><li><a href="LayerUtil.html">LayerUtil</a><ul class='methods'><li data-type='method' style='display: none;'><a href="LayerUtil.html#lazyLoadingLayer">lazyLoadingLayer</a></li><li data-type='method' style='display: none;'><a href="LayerUtil.html#applyLayer">applyLayer</a></li><li data-type='method' style='display: none;'><a href="LayerUtil.html#applyMapImageLayer">applyMapImageLayer</a></li><li data-type='method' style='display: none;'><a href="LayerUtil.html#applyTileLayer">applyTileLayer</a></li><li data-type='method' style='display: none;'><a href="LayerUtil.html#applyFeatureLayer">applyFeatureLayer</a></li><li data-type='method' style='display: none;'><a href="LayerUtil.html#applySceneLayer">applySceneLayer</a></li><li data-type='method' style='display: none;'><a href="LayerUtil.html#applyElevationLayer">applyElevationLayer</a></li><li data-type='method' style='display: none;'><a href="LayerUtil.html#switchLayer">switchLayer</a></li><li data-type='method' style='display: none;'><a href="LayerUtil.html#getLayerByUniqueId">getLayerByUniqueId</a></li></ul></li><li></li><li><a href="ViewUtil.html">ViewUtil</a><ul class='methods'><li data-type='method' style='display: none;'><a href="ViewUtil.html#flyToPosition3D">flyToPosition3D</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#flyToPoint2D">flyToPoint2D</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#applyMapView">applyMapView</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#removeMapView">removeMapView</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#applySceneView">applySceneView</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#removeSceneView">removeSceneView</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#getMapStatus">getMapStatus</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#getMap">getMap</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#getMapViewMap">getMapViewMap</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#getSceneViewMap">getSceneViewMap</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#getView">getView</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#getMapView">getMapView</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#getSceneView">getSceneView</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#bind2D_3D">bind2D_3D</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#switchView">switchView</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#addMapSwitchEvent">addMapSwitchEvent</a></li><li data-type='method' style='display: none;'><a href="ViewUtil.html#removeMapSwitchEvent">removeMapSwitchEvent</a></li></ul></li><li></li><li><a href="OverViewUtil.html">OverViewUtil</a><ul class='methods'><li data-type='method' style='display: none;'><a href="OverViewUtil.html#updateOverview">updateOverview</a></li><li data-type='method' style='display: none;'><a href="OverViewUtil.html#updateOverviewExtent">updateOverviewExtent</a></li><li data-type='method' style='display: none;'><a href="OverViewUtil.html#remove">remove</a></li><li data-type='method' style='display: none;'><a href="OverViewUtil.html#switchOverview">switchOverview</a></li><li data-type='method' style='display: none;'><a href="OverViewUtil.html#getOverViewMapId">getOverViewMapId</a></li></ul></li><li></li><li><a href="ScaleBarUtil.html">ScaleBarUtil</a><ul class='methods'><li data-type='method' style='display: none;'><a href="ScaleBarUtil.html#defaultStyle">defaultStyle</a></li><li data-type='method' style='display: none;'><a href="ScaleBarUtil.html#remove">remove</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-arcgisTools.html">arcgisTools</a><ul class='methods'><li data-type='method' style='display: none;'><a href="module-arcgisTools.html#~loadAPI">loadAPI</a></li></ul></li><li><a href="module-layer_layerManage.html">layer/layerManage</a><ul class='methods'><li data-type='method' style='display: none;'><a href="module-layer_layerManage.html#~switchLayers">switchLayers</a></li><li data-type='method' style='display: none;'><a href="module-layer_layerManage.html#~switchLayer">switchLayer</a></li><li data-type='method' style='display: none;'><a href="module-layer_layerManage.html#~lazyLoadingLayer">lazyLoadingLayer</a></li><li data-type='method' style='display: none;'><a href="module-layer_layerManage.html#~applyLayerByUrl">applyLayerByUrl</a></li><li data-type='method' style='display: none;'><a href="module-layer_layerManage.html#~applyLayerByConfig">applyLayerByConfig</a></li><li data-type='method' style='display: none;'><a href="module-layer_layerManage.html#~applyMapImageLayerByUrl">applyMapImageLayerByUrl</a></li><li data-type='method' style='display: none;'><a href="module-layer_layerManage.html#~applyMapImageLayerByConfig">applyMapImageLayerByConfig</a></li><li data-type='method' style='display: none;'><a href="module-layer_layerManage.html#~applyTileLayerByUrl">applyTileLayerByUrl</a></li><li data-type='method' style='display: none;'><a href="module-layer_layerManage.html#~applyTileLayerByConfig">applyTileLayerByConfig</a></li><li data-type='method' style='display: none;'><a href="module-layer_layerManage.html#~applyElevationLayerByUrl">applyElevationLayerByUrl</a></li><li data-type='method' style='display: none;'><a href="module-layer_layerManage.html#~applyElevationLayerByConfig">applyElevationLayerByConfig</a></li></ul></li><li><a href="module-view_viewManage.html">view/viewManage</a><ul class='methods'><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~flyToPosition3D">flyToPosition3D</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~flyToPoint2D">flyToPoint2D</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~applyMapView">applyMapView</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~removeMapView">removeMapView</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~removeSceneView">removeSceneView</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~applySceneView">applySceneView</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~getMapStatus">getMapStatus</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~getMap">getMap</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~getMapViewMap">getMapViewMap</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~getSceneViewMap">getSceneViewMap</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~getView">getView</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~getMapView">getMapView</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~getSceneView">getSceneView</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~bind2D_3D">bind2D_3D</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~switchView">switchView</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~addMapSwitchEvent">addMapSwitchEvent</a></li><li data-type='method' style='display: none;'><a href="module-view_viewManage.html#~removeMapSwitchEvent">removeMapSwitchEvent</a></li></ul></li><li><a href="module-widgets_widgetsManage.html">widgets/widgetsManage</a><ul class='methods'><li data-type='method' style='display: none;'><a href="module-widgets_widgetsManage.html#~addScaleBar">addScaleBar</a></li><li data-type='method' style='display: none;'><a href="module-widgets_widgetsManage.html#~removeScaleBar">removeScaleBar</a></li><li data-type='method' style='display: none;'><a href="module-widgets_widgetsManage.html#~addOverview">addOverview</a></li><li data-type='method' style='display: none;'><a href="module-widgets_widgetsManage.html#~getOverViewMapId">getOverViewMapId</a></li><li data-type='method' style='display: none;'><a href="module-widgets_widgetsManage.html#~removeOverview">removeOverview</a></li><li data-type='method' style='display: none;'><a href="module-widgets_widgetsManage.html#~switchOverview">switchOverview</a></li></ul></li></ul>
</nav>

<div id="main">
    
    <h1 class="page-title">layer/layerManage.js</h1>
    

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>import {LayerUtil} from './LayerUtil'
import {viewManage} from "../view/viewManage";

/**
 * @module
 */
export const layerManage = {};
const saveMyLayer = new Map();

/**
 * 切换多个图层
 * @function switchLayers
 * @param {String} mapId 地图的mapId
 * @param {String} uniqueId 内部识别的唯一的标识s
 * @param {Boolean} visible 是否显示
 */
layerManage.switchLayers = function (mapId, uniqueIds, visible) {
  for (let uniqueId of uniqueIds) {
    this.switchLayer(mapId, uniqueId, visible);
  }
}
/**
 * 切换单个图层
 * @function switchLayer
 * @param {String} mapId 地图的mapId
 * @param {String} uniqueId 内部识别的唯一的标识
 * @param {Boolean} visible 是否显示
 */
layerManage.switchLayer = function (mapId, uniqueId, visible) {
  //TODO 把该图层移动到最顶层
  let myLayer = applyMyLayer(mapId);
  let map = viewManage.getMap(mapId);
  myLayer.switchLayer(map, uniqueId, visible);
}
/**
 * 懒加载图层配置项
 * @function lazyLoadingLayer
 * @param {String} mapId 地图的mapId
 * @param  {Array}  configs 配置项数组
 */
layerManage.lazyLoadingLayer = function (mapId, configs) {
  let myLayer = applyMyLayer(mapId);
  let map = viewManage.getMap(mapId);
  myLayer.lazyLoadingLayer(map, configs);
}
/** 根据url和tyoe加载图层
 * @function applyLayerByUrl
 * @param {String} mapId 地图的mapId
 * @param {String} uniqueId 内部识别的唯一的标识
 * @param {Stirng} uniqueType 需要使用什么方式加载改该图层
 * @param {String} url 图层的地址
 * @returns {Object|*}
 */
layerManage.applyLayerByUrl = function (mapId, uniqueId, uniqueType, url) {
  let config = {uniqueId, uniqueType, url}
  let layer = this.applyLayerByConfig(mapId, config);
  return layer;
}

/**
 * 根据config加载图层
 * @function applyLayerByConfig
 * @param {String} mapId 地图的mapId
 * @param {Object}  config 配置项
 * @returns {Object|*}
 */
layerManage.applyLayerByConfig = function (mapId, config) {
  let myLayer = applyMyLayer(mapId);
  let layer = myLayer.applyLayer(config);
  mapId &amp;&amp; viewManage.getMap(mapId) &amp;&amp;  viewManage.getMap(mapId).add(layer);
  return layer;
}

/**
 * 根据url加载MapImageLayer
 * @function applyMapImageLayerByUrl
 * @param {String} mapId 地图的mapId
 * @param {String} uniqueId 内部识别的唯一的标识
 * @param {String} url 图层的地址
 * @returns {Object}
 */
layerManage.applyMapImageLayerByUrl = function (mapId, uniqueId, url) {
  let config = {uniqueId, url};
  let layer = this.applyMapImageLayerByConfig(mapId, config);
  return layer;
}
/**
 * 根据config加载MapImageLayer
 * @function applyMapImageLayerByConfig
 * @param {String} mapId 地图的mapId
 * @param {Object}  config 配置项
 * @returns {Object}
 */
layerManage.applyMapImageLayerByConfig = function (mapId, config) {
  let myLayer = applyMyLayer(mapId);
  let layer = myLayer.applyMapImageLayer(config);
  mapId &amp;&amp; viewManage.getMap(mapId) &amp;&amp;  viewManage.getMap(mapId).add(layer);
  return layer;
}
/**
 * 根据url加载TileLayer
 * @function applyTileLayerByUrl
 * @param {String} mapId 地图的mapId
 * @param {String} uniqueId 内部识别的唯一的标识
 * @param {String} url 图层的地址
 * @returns {Object}
 */
layerManage.applyTileLayerByUrl = function (mapId, uniqueId, url) {
  let config = {uniqueId, url};
  let layer = this.applyTileLayerByConfig(mapId, config);
  return layer;
}
/**
 * 根据config加载TileLayer
 * @function applyTileLayerByConfig
 * @param {String} mapId 地图的mapId
 * @param {Object}  config 配置项
 * @returns {Object}
 */
layerManage.applyTileLayerByConfig = function (mapId, config) {
  let myLayer = applyMyLayer(mapId);
  let layer = myLayer.applyTileLayer(config);
  mapId &amp;&amp; viewManage.getMap(mapId) &amp;&amp;  viewManage.getMap(mapId).add(layer);
  return layer;
}

/**
 * 根据url加载ElevationLayer
 * @function applyElevationLayerByUrl
 * @param {String} mapId 地图的mapId
 * @param {String} uniqueId 内部识别的唯一的标识
 * @param {String} url 图层的地址
 * @returns {Object}
 */
layerManage.applyElevationLayerByUrl = function (mapId, uniqueId, url) {
  let config = {uniqueId, url};
  let layer = this.applyElevationLayerByConfig(mapId, config);
  return layer;
}
/**
 * 根据config加载ElevationLayer
 * @function applyElevationLayerByConfig
 * @param {String} mapId 地图的mapId
 * @param {Object}  config 配置项
 * @returns {Object}
 */
layerManage.applyElevationLayerByConfig = function (mapId, config) {
  let myLayer = applyMyLayer(mapId);
  let layer = myLayer.applyElevationLayer(config);
  mapId &amp;&amp; viewManage.getMap(mapId) &amp;&amp;  viewManage.getMap(mapId).add(layer);
  return layer;
}


layerManage.getLayerByUniqueId = function (mapId,uniqueId) {
  let myLayer = applyMyLayer(mapId);
  let layer = myLayer.getLayerByUniqueId(null,uniqueId);
  return layer;
}


/**
 * 申请MyLayer对象，如果存在，直接返回已有的对象
 * @private
 * @param {String} mapId 地图的mapId
 * @returns {*}
 */
function applyMyLayer(mapId) {
  if (saveMyLayer.has(mapId)) {
    return saveMyLayer.get(mapId);
  } else {
    let myLayer = new LayerUtil();
    if(mapId){
      saveMyLayer.set(mapId, myLayer);
    }
    return myLayer;
  }
}
</code></pre>
        </article>
    </section>




    
    
</div>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat May 11 2019 22:54:19 GMT+0800 (GMT+08:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>

<script src="scripts/search.js" defer></script>


<script src="scripts/collapse.js" defer></script>


</body>
</html>
